#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>

static Display * gbv_dpy;
static Window gbv_rootw;

void
xo_set_status ( char * iv_status )
{
	if ( iv_status == NULL )
	{
		fprintf( stderr, "WARNING: trying to output null string.\n" );
		return;
	}

	XStoreName( gbv_dpy, gbv_rootw, iv_status );
	XFlush( gbv_dpy );
}

void
xo_display_attach ( void )
{
	gbv_dpy = XOpenDisplay( NULL );
	if ( gbv_dpy == NULL )
	{
		fprintf( stderr, "ERROR: could not open display\n" );
		exit( 1 );
	}

	gbv_rootw = XRootWindow( gbv_dpy, DefaultScreen( gbv_dpy ) );
}

void
xo_display_detach ( void )
{
	XCloseDisplay( gbv_dpy );
	return;
}
